import Vue from 'vue'
import VueRouter from 'vue-router'

// 登录注册
import login from '../view/login.vue'
// // 引入页面路由
import Main from '../view/richtext/Main.vue'
import Echarts from '../view/echarts/echarts.vue'
Vue.use(VueRouter)

// 使用下面四行代码  把 错误进行拦截 并不处理
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes: [
    // 当路由为 / 时，跳转到 login 页面
    { path: '/', redirect: 'login'},
    { path: '/login', name: 'login', component: login },
    { path: '/Main', name: 'Main', component: Main },
    { path: '/Echarts', name: 'Echarts', component: Echarts },
    // 信息页面
    // {
    //   path: '/Main',
    //   name: 'Main',
    //   component: Main,
    //   children: [
    //     { path: '/user', name: 'user', component: User },
    //     { path: '/work', name: 'work', component: Work },
    //     { path: '/project', name: 'project', component: Project },
    //     { path: '/share', name: 'share', component: Share },
    //     { path: '/index', name: 'index', component: index },
    //     { path: '/ali', name: 'ali', component: ali },
    //   ],
    // },
  ],
})

export default router
